package <%-props.packageName%>.<%-props.servicePackage%>;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
<%
var className = tb.className;
var priName = tb.pri[0]?under2Camel(tb.pri[0].COLUMN_NAME):"";
var priType = tb.pri[0]?under2Camel(tb.pri[0].JavaType):"";
%>
import <%-props.packageName%>.<%-props.mapperPackage%>.<%-className%>Mapper;
import <%-props.packageName%>.<%-props.entityPackage%>.<%-className%>;

@Service
public class <%-className%>Service {
	
	
	@Resource
	private <%-className%>Mapper <%-tb.camel%>Mapper;
	
	<%if(!props.Simple){%>
	public List<<%-className%>> findAll() throws Exception {
		List<<%-className%>> <%-tb.camel%><%-props.listName%> = <%-tb.camel%>Mapper.findAll();
		return <%-tb.camel%><%-props.listName%>;
	}
	<%
		if(priName){
	%>
	public <%-className%> findByPrimaryKey(<%-camel2Pascl(priType)%> <%-priName%>) throws Exception {
		<%-className%> <%-tb.camel%> = <%-tb.camel%>Mapper.findByPrimaryKey(<%-priName%>);
		return <%-tb.camel%>;
	}
	<%}%>
	public List<<%-className%>> findByPojo(<%-className%> <%-tb.camel%>) throws Exception {
		List<<%-className%>> <%-tb.camel%><%-props.listName%> = <%-tb.camel%>Mapper.findByPojo(<%-tb.camel%>);
		return <%-tb.camel%><%-props.listName%>;
	}


	public List<<%-className%>> findByPage(int num,int size) throws Exception {
		
		List<<%-className%>> <%-tb.camel%><%-props.listName%> = <%-tb.camel%>Mapper.findByPage(num,size);
		return <%-tb.camel%><%-props.listName%>;
	}
	@Transactional
	public Boolean updateByPojo(<%-className%> <%-tb.camel%>) throws Exception {
		Boolean result = <%-tb.camel%>Mapper.updateByPojo(<%-tb.camel%>);
		return result;
	}
	@Transactional
	public Boolean insert(<%-className%> <%-tb.camel%>) throws Exception {
		Boolean result = <%-tb.camel%>Mapper.insert(<%-tb.camel%>);
		return result;
	}
	
	@Transactional
	public Boolean insertList(List<<%-className%>> <%-tb.camel%><%-props.listName%>) throws Exception {
		Boolean result = <%-tb.camel%>Mapper.insertList(<%-tb.camel%><%-props.listName%>);
		return result;
	}

	<%-include(extrucPath(path.join(dirname,"uni_service.ejs")),{tb:tb,className:className})%>
	<%}%>
}
